import {getCms} from '../services/api';

export default {
  namespace: 'cms',

  state: {
    item: {},
  },

  effects: {
    * get({payload}, {call, put}) {
      const result = yield call(getCms, payload);
      if (result && result.code === 0) {
        yield put({
          type: 'save',
          payload: {
            item: result.data,
          }
        });
      }
    },
  },

  reducers: {
    save(state, {payload}) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
